#!/bin/bash
#This stuff runs as the conimbo user!
echo "Start of configure_aegir.sh"
echo "download drush-make 2.3"
sudo -u conimbo -i drush dl drush_make-6.x-2.3
echo "set up the www directory"
sudo -u conimbo mkdir /home/conimbo/www 
echo "download and install drupal-6.26 as hostmaster-1.9"
sudo -u conimbo -i drush dl drupal-6.26 --destination=/home/conimbo/www --drupal-project-rename=hostmaster-1.9
echo "download and deploy the provision part of Aegir"
sudo -u conimbo -i drush dl provision-6.x-1.9
echo "extract the prepared hostmaster-1.9 build from resources"
sudo -u conimbo tar xvfz /vagrant/resources/hostmaster-1.9.tar.gz -C /home/conimbo/www/hostmaster-1.9/
echo "Add read access for other users"
chmod -R +x /home/conimbo/www
echo "Set up aegir"
sudo -u conimbo -i drush -y hostmaster-install --aegir_host=vagrant-ubuntu-hardy64 --aegir_root=/home/conimbo --aegir_db_host=localhost --aegir_db_user=conimbo --aegir_db_pass=conimbo --root=/home/conimbo/www/hostmaster-1.9 --version=1.9   --debug --client_email=bart.declercq@fedict.be --client_name=admin
ln -s /home/conimbo/config/apache.conf /etc/apache2/sites-enabled/002-conimbo
echo "to regenerate a one time login url"
echo "as conimbo user execute 'cd ~/www/hostmaster-1.9/sites/vagrant-ubuntu-hardy64/ && drush uli admin"
echo "restart apache"
apache2ctl restart
echo "End of configure_aegir.sh"
